from datetime import datetime
from typing import Optional, List
from pydantic import BaseModel, Field
from app.models.meeting import MeetingStatus


class MeetingBase(BaseModel):
    """会议基础模型"""
    title: str = Field(..., min_length=1, max_length=200)
    description: Optional[str] = Field(None, max_length=1000)
    language: str = Field(default="zh-CN", regex="^[a-z]{2}-[A-Z]{2}$")


class MeetingCreate(MeetingBase):
    """创建会议请求模型"""
    pass


class MeetingUpdate(BaseModel):
    """更新会议请求模型"""
    title: Optional[str] = Field(None, min_length=1, max_length=200)
    description: Optional[str] = Field(None, max_length=1000)
    status: Optional[MeetingStatus] = None


class Meeting(MeetingBase):
    """会议响应模型"""
    id: int
    user_id: int
    audio_file_name: Optional[str] = None
    audio_file_size: Optional[int] = None
    duration: Optional[float] = None
    status: MeetingStatus
    error_message: Optional[str] = None
    created_at: datetime
    updated_at: Optional[datetime] = None

    class Config:
        from_attributes = True


class MeetingWithDetails(Meeting):
    """带详细信息的会议模型"""
    transcript_count: int = 0
    has_minutes: bool = False
    minutes_status: Optional[str] = None


class MeetingList(BaseModel):
    """会议列表响应模型"""
    meetings: List[MeetingWithDetails]
    total: int
    page: int
    size: int
    pages: int